#ifndef TEST_H
#define TEST_H

#include <stdio.h>
#include <iostream>
#include <fstream>
#include <exception>
#include <QString>
#include <QDateTime>

using namespace std;

class test{

public:

    test()
    {

    }
    ~test()
    {

    }

    void _printInt(int *_data, int _height, int _width)
    {
        QString _output = "./output/test/";

        _output = _output.append(_getTime() + "int.csv");

        try
        {
            ofstream _fout(_output.toStdString().c_str());

            for(int i=0; i<_height; i++)
            {
                for(int j=0; j<_width; j++)
                {
                    _fout << _data[i*_width+j] << ",";
                }
                _fout << "\n";
            }
            _fout.close();
        }
        catch(exception &e)
        {
            qDebug() << e.what();
        }
    }

    void _printFloat(float *_data, int _height, int _width)
    {
        QString _output = "./output/test/";

        _output = _output.append(_getTime() + "float.csv");

        try
        {
            ofstream _fout(_output.toStdString().c_str());

            for(int i=0; i<_height; i++)
            {
                for(int j=0; j<_width; j++)
                {
                    _fout << _data[i*_width+j] << ",";
                }
                _fout << "\n";
            }
            _fout.close();
        }
        catch(exception &e)
        {
            qDebug() << e.what();
        }
    }

private:
    QString _getTime()
    {
        QString _output;
        // output file name contain current time
        QDateTime now = QDateTime::currentDateTime();

        _output = _output.append(QString::number(now.date().year()) + "_");
        _output = _output.append(QString::number(now.date().month()) + "_");
        _output = _output.append(QString::number(now.date().day()) + "_");
        _output = _output.append(QString::number(now.time().hour()) + "_");
        _output = _output.append(QString::number(now.time().minute()) + "_");
        _output = _output.append(QString::number(now.time().second()) + "_");

        return _output;
    }

};
#endif // TEST_H
